package com.weimob.mcloud.wechatwork.customer.service.user.base;

import com.weimob.mcloud.wechatwork.customer.service.user.exception.BaseErrorCode;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author yu liu  2022/7/22 18:21
 * Description
 * Version 1.0.0
 **/
@Data
public class PaasBaseResponse<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 通用成功响应对象 */
    private T data;

    private ResponseCode code;

    private String globalTicket;


    public void  setCodeByErrorCode(BaseErrorCode baseErrorCode){
        ResponseCode code = new ResponseCode();
        code.setErrcode(baseErrorCode.getCode().toString());
        code.setErrmsg(baseErrorCode.getMsg());
        this.setCode(code);
    }

    public void  setCodeByErrorCode(String errorCode,String msg ){
        ResponseCode code = new ResponseCode();
        code.setErrcode(errorCode);
        code.setErrmsg(msg);
        this.setCode(code);
    }

    @Data
    public class ResponseCode implements Serializable {
        private static final long serialVersionUID = 1L;

        private final static String RETURN_SUCCESS = "000000";
        private String errcode = RETURN_SUCCESS;

        private String errmsg;
    }
}
